summaryrefslogtreecommitdiff
path: root/bloodfields.stage
blob: 7b61dd49b519578e6ba33a50b3600f2752ced1d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
game.title = "Bloodfields";

global
{
	command: "quit"
	{
		exit();
	}
}

situation <<start>>
{
	setup
	{
		global.enemyTypes = {
			1: {
				'name': 'Snail',
				'action': 'bites',
				'hp': 3,
				'attack': 2
			},
			2: {
				'name': 'Wolf',
				'action': 'bites',
				'hp': 7,
				'attack': 3
			},
			3: {
				'name': 'Snake',
				'action': 'strikes at',
				'hp': 3,
				'attack': 3
			}
		};

		global.enemyMods = {
			1: {
				'name': 'Pathetic',
				'hp': 0,
				'attack': 0
			},
			2: {
				'name': 'Sickly',
				'hp': 3,
				'attack': 1
			},
			3: {
				'name': 'Wimpy',
				'hp': 5,
				'attack': 2
			}
		};

		player.hpMax = 10;
		player.hpCur = player.hpMax;
		player.xp = 0;
		player.attack = 3;

		global.bJustTravelled = false;

		goto( <<field>> );
	}
}

function status()
{
	display('You have ' + player.hpCur + ' of ' + player.hpMax + ' hp.');
}

function look()
{
	if( exists(global.enemy) )then
	{
		display('''You are standing in a field of wheat.  You see a ''' +
			global.enemy['name'] + ''' in front of you.''');
	}
	else
	{
		display('''You are standing in a field of wheat.''');
	}
//	status();
}

function mkEnemy()
{
	eid = random( 1, 3 );
	global.enemy = global.enemyTypes[eid];

	mod = 1;
	global.enemy['name'] = global.enemyMods[mod]['name'] + ' ' +
		global.enemy['name'];
	global.enemy['attack'] = global.enemy['attack'] +
		global.enemyMods[mod]['attack'];
	global.enemy['hp'] = global.enemy['hp'] + global.enemyMods[mod]['hp'];
}

function rollAttack( attack )
{
	return( random( attack-attack/3, attack+attack/3 ) );
}

function playerAttack()
{
	damage = rollAttack( player.attack );
	global.enemy['hp'] = global.enemy['hp'] - damage;
	display('You strike the ' + global.enemy['name'] + ' for ' + damage +
		' damage.');
	if global.enemy['hp'] <= 0 then
	{
		display('You killed the ' + global.enemy['name'] + '!');
		delete( global.enemy );
	}
}

function enemyAttack()
{
	damage = rollAttack( global.enemy['attack'] );
	player.hpCur -= damage;
	display("The " + global.enemy['name'] + ' ' + global.enemy['action'] +
		' you for ' + damage + ' damage.');
	if player.hpCur <= 0 then
	{
		display('The ' + global.enemy['name'] + ' killed you!');
		exit();
	}
}

situation <<travel>>
{
	enter
	{
		delete( global.enemy );
		
		display('You wander aimlessly through the seemingly endless field of wheat.');

		select = random(1,3);
		if select == 1 then
		{
			mkEnemy();
			display('''There's a ''' + global.enemy['name'] + ''' here!''');
		}

		global.bJustTravelled = true;

		goto( <<field>> );
	}
}

situation <<field>>
{
	command: "attack"
	{
		if exists(global.enemy) then
		{
			playerAttack();
			goto( <<field>> );
		}
		else
		{
			display('''There's nothing here to attack...''');
		}
	}

	command: "look"
	{
		look();
	}

	command: "walk"
	{
		if not exists(global.enemy) then
		{
			goto( <<travel>> );
		}
		else
		{
			display("You can't walk around with an enemy in front of you! 
				You can try to flee if you'd like...");
		}
	}

	setup
	{
		look();
	}

	enter
	{
		if not global.bJustTravelled then
		{
			if exists( global.enemy ) then
			{
				enemyAttack();
			}
			status();
//			look();
		}
		else
		{
		}
		global.bJustTravelled = false;
	}
}